using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace PUCIT.eFCS.DataAccess.Models.Mapping
{
    public class field_dataMap : EntityTypeConfiguration<field_data>
    {
        public field_dataMap()
        {
            // Primary Key
            this.HasKey(t => t.field_dataId);

            // Properties
            this.Property(t => t.value)
                .IsRequired();

            // Table & Column Mappings
            this.ToTable("field_data");
            this.Property(t => t.field_dataId).HasColumnName("field_dataId");
            this.Property(t => t.formId).HasColumnName("formId");
            this.Property(t => t.fieldId).HasColumnName("fieldId");
            this.Property(t => t.sectionId).HasColumnName("sectionId");
            this.Property(t => t.value).HasColumnName("value");

            // Relationships
            this.HasRequired(t => t.field)
                .WithMany(t => t.field_data)
                .HasForeignKey(d => d.fieldId);
            this.HasRequired(t => t.section)
                .WithMany(t => t.field_data)
                .HasForeignKey(d => d.sectionId);
            this.HasRequired(t => t.form)
                .WithMany(t => t.field_data)
                .HasForeignKey(d => d.formId);

        }
    }
}
